package com.bleeth.fx.component;

import com.bleeth.fx.helper.SStyleHelper;
import javafx.geometry.Pos;
import javafx.scene.control.Label;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Region;
import javafx.scene.text.TextAlignment;
import lombok.Builder;

/**
 * @author Sakura
 * @version 1.0
 * @date 2021-11-23 23:08
 **/
@Builder
public class MShield {

    private String name;

    private String value;

    @Builder.Default
    private String color = "#0883c4";


    public Region make() {
        HBox root = new HBox();

        Label nameLabel = new Label();
        nameLabel.setText("  "+name+"  ");
        nameLabel.setTextAlignment(TextAlignment.CENTER);
        nameLabel.setAlignment(Pos.CENTER);

        Label valueLabel = new Label();
        valueLabel.setText("  "+value+"  ");
        valueLabel.setTextAlignment(TextAlignment.CENTER);
        valueLabel.setAlignment(Pos.CENTER);

        //设置样式
        SStyleHelper.node(nameLabel)
                .addStyle("-fx-background-radius", "5 0 0 5")
                .addStyle("-fx-pref-height", "22")
                .addStyle("-fx-background-color", "#545454")
                .addStyle("-fx-text-fill","#f9f4f3")
                .addStyle("-fx-font-size","14")
                .apply();
        SStyleHelper.node(valueLabel)
                .addStyle("-fx-background-radius", "0 5 5 0")
                .addStyle("-fx-pref-height", "22")
                .addStyle("-fx-background-color", color)
                .addStyle("-fx-text-fill","#f9f4f3")
                .addStyle("-fx-font-size","14")
                .apply();

        root.getChildren().addAll(nameLabel, valueLabel);
        return root;
    }

}
